package guowenlong.golf.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.HashMap;

import butterknife.ButterKnife;
import me.wenlong.mixutils.mvp.BaseModel;
import me.wenlong.mixutils.mvp.BasePresenter;
import me.wenlong.mixutils.mvp.BaseView;
import me.wenlong.mixutils.util.MvpUtils;

/**
 * des   : Fragment基类 author: Gavin email : guowenlong20000@gmail.com time  : 2016年05月31日 上午 11:32.
 */
public abstract class BaseFragment<T extends BasePresenter, E extends BaseModel> extends
    me.wenlong.mixutils.mvp.BaseFragment {

  public View view;
  protected HashMap<String, Object> mFromMap;
  public T mPresenter;
  public E mModel;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutId(), null);
    ButterKnife.bind(this, view);
    return view;
  }

  public void setFromMap(HashMap<String, Object> map) {
    this.mFromMap = map;
  }

  public abstract int getLayoutId();

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    mPresenter = MvpUtils.getT(this, 0);
    mModel = MvpUtils.getT(this, 1);
    if (this instanceof BaseView) {
      mPresenter.setVM(this, mModel);
    }
    super.onActivityCreated(savedInstanceState);
  }

  @Override
  public View initContantView(LayoutInflater inflater) {
    return null;
  }
}